from django.conf import settings
from django.conf.urls.defaults import *
from com.ericyang.common.web import url_redirect, page404
from django.contrib.auth.views import login, logout

urlpatterns = patterns('',
   
     # incex
    (r'^$', "com.ericyang.groupshopping.index.views.index_page"),
    
    (r'^login/$', login, { 'template_name': 'user/user_login.html'}),
    (r'^logout/$', logout, { 'template_name': 'user/user_login.html'}),
    (r'^register/$', "com.ericyang.groupshopping.user.views.register"),
    
    #static file url
    (r'^css/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.BASE_TEMPLATE_DIR + '/css'}),
    (r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.BASE_TEMPLATE_DIR + '/images'}),
    (r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.BASE_TEMPLATE_DIR + "/js" }),
    (r'^img/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.ROOT_PATH + "/img" }),
    
    #common url configuration
    (r'^common/', include('com.ericyang.groupshopping.common.urls')),
     
    # redirct admin accounts url
    (r'^accounts/(.*)', url_redirect('/user/')),
    
    # user urls
    (r'^user/', include('com.ericyang.groupshopping.user.urls')),
    
    # address book urls
    (r'^addressbook/', include('com.ericyang.groupshopping.addressbook.urls')),
    
    # company urls
    (r'^company/', include('com.ericyang.groupshopping.company.urls')),
    
    # product urls
    (r'^product/', include('com.ericyang.groupshopping.product.urls')),
    
    # order urls
    (r'^order/', include('com.ericyang.groupshopping.order.urls')),
    
    # polls urls
    (r'^polls/', include('python.common.polls.urls')),
    
    # test url
    (r'^test/', 'com.ericyang.groupshopping.test.view.test'),
    
    (r'^i18n/', include('django.conf.urls.i18n')),
   
    #404 page
    (r'^(.*)', page404()),
)
